import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/login.vue'
import Dynamic from './views/DynamicRoute'
import nastedRoute from './views/nestedRoutes'

Vue.use(Router)

export default new Router({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/',
      name: 'login',
      meta:{admin:true},
      component: Home
    },
    {
      path:'/Dynamic',
      name:'Dynamic',
      meta:{header:true},
      component: Dynamic
    },
    {
      path: '/param/:id',
      name: 'param',
      component:() => import('./views/DynamicRoute/param.vue') 
    },
    {
      path:'/nestedRoute',
      name:'nastedRoute',
      // redirect:'/child1',//路由路径重定向
      // redirect: { name:'child2'},//使用路由名字重定向
      // 使用方法重定向
       redirect: (to) =>{
         console.log(to);
          return '/child3'
       } ,
       
        component:nastedRoute,
      children:[
        {
          path:'/child1/:id',
          name:'child1',
          component:() => import('./views/nestedRoutes/child1.vue')
        },
        {
          path: '/child2',
          name: 'child2',
          component: () => import('./views/nestedRoutes/child2.vue')
        },
        {
          path: '/child3',
          name: 'child3',
          alias: '/child2',
          component: () => import('./views/nestedRoutes/child3.vue')
        },
      ]
    },
    {
      path:'/navigation',
      name:'navigation',
      component: () => import('./views/navigation')
    }
  ]
})
